home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / e_to_l / isamexpt / isamexpt.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-15  |  34KB  |  1,045 lines

  1. {C 1996 Stellberg GmbH}
  2. { HISTORY OF CHANGES:  see CHANGES.PAS }
  3. unit Isamexpt;
  4.  
  5. interface
  6.  
  7. uses
  8.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  9.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, ToolIntf,
  10.   ExptIntf;
  11.  
  12. type
  13.   TIsamMainForm = class(TForm)
  14.     StatusLine: TPanel;
  15.     OpenDialog1: TOpenDialog;
  16.     SaveDialog1: TSaveDialog;
  17.     Sample: TPaintBox;
  18.     Notebook1: TNotebook;
  19.     GroupBox1: TGroupBox;
  20.     CancelBttn: TBitBtn;
  21.     Rueckbttn: TBitBtn;
  22.     VorBttn: TBitBtn;
  23.     GroupBox2: TGroupBox;
  24.     EdiHauptCheck: TCheckBox;
  25.     GroupBox4: TGroupBox;
  26.     BrwHauptCheck: TCheckBox;
  27.     FileopenBttn: TSpeedButton;
  28.     GroupBox5: TGroupBox;
  29.     Label7: TLabel;
  30.     Label4: TLabel;
  31.     Edit1: TEdit;
  32.     Label3: TLabel;
  33.     SpeedButton1: TSpeedButton;
  34.     Label6: TLabel;
  35.     Edit3: TEdit;
  36.     SpeedButton3: TSpeedButton;
  37.     BrwCheck: TCheckBox;
  38.     EdiCheck: TCheckBox;
  39.     Label9: TLabel;
  40.     DirInput: TEdit;
  41.     SpeedButton4: TSpeedButton;
  42.     Label10: TLabel;
  43.     Label11: TLabel;
  44.     IniDatNamInput: TEdit;
  45.     IniBrwNamInput: TEdit;
  46.     GroupBox6: TGroupBox;
  47.     LabelNebenRadio: TRadioButton;
  48.     LabelueberRadio: TRadioButton;
  49.     GroupBox7: TGroupBox;
  50.     LenFestRadio: TRadioButton;
  51.     LenVarRadio: TRadioButton;
  52.     EdiFontLabel: TLabel;
  53.     EdiInputFontLabel: TLabel;
  54.     SpeedButton5: TSpeedButton;
  55.     SpeedButton6: TSpeedButton;
  56.     FontDialog1: TFontDialog;
  57.     SpeedButton7: TSpeedButton;
  58.     LboxFontLabel: TLabel;
  59.     Memo1: TMemo;
  60.     GroupBox9: TGroupBox;
  61.     Memo2: TMemo;
  62.     GroupBox10: TGroupBox;
  63.     Memo3: TMemo;
  64.     Label2: TLabel;
  65.     TableNameInput: TEdit;
  66.     HelpBttn: TBitBtn;
  67.     SprachBttn: TBitBtn;
  68.     DateiBttn: TSpeedButton;
  69.     OpenDialog2: TOpenDialog;
  70.     EditorFormNameInput: TEdit;
  71.     BrwFormNameInput: TEdit;
  72.     Label1: TLabel;
  73.     DBaseExpCheck: TCheckBox;
  74.     DBaseImpCheck: TCheckBox;
  75.     DBStruEdit: TEdit;
  76.     Label5: TLabel;
  77.     DBStruBttn: TSpeedButton;
  78.     TblCreatCheck: TCheckBox;
  79.     SaveTypBttn: TBitBtn;
  80.     SaveDialog2: TSaveDialog;
  81.     BrwSetupCheck: TCheckBox;
  82.     AliasEdit: TComboBox;
  83.     Label8: TLabel;
  84.     procedure FormCreate(Sender: TObject);
  85.     procedure ShowHint(Sender: TObject);
  86.     procedure FileopenBttnClick(Sender: TObject);
  87.     procedure EndeBttnClick(Sender: TObject);
  88.     procedure FormDestroy(Sender: TObject);
  89.     procedure SamplePaint(Sender: TObject);
  90.     procedure EdiCheckClick(Sender: TObject);
  91.     procedure CancelBttnClick(Sender: TObject);
  92.     procedure RueckbttnClick(Sender: TObject);
  93.     procedure VorBttnClick(Sender: TObject);
  94.     procedure EdiHauptCheckClick(Sender: TObject);
  95.     procedure BrwHauptCheckClick(Sender: TObject);
  96.     procedure SpeedButton1Click(Sender: TObject);
  97.     procedure SpeedButton3Click(Sender: TObject);
  98.     procedure SpeedButton4Click(Sender: TObject);
  99.     procedure SpeedButton5Click(Sender: TObject);
  100.     procedure SpeedButton6Click(Sender: TObject);
  101.     procedure SpeedButton7Click(Sender: TObject);
  102.     procedure Memo1Exit(Sender: TObject);
  103.     procedure HelpBttnClick(Sender: TObject);
  104.     procedure FormKeyDown(Sender: TObject; var Key: Word;
  105.       Shift: TShiftState);
  106.     procedure FormShow(Sender: TObject);
  107.     procedure SprachBttnClick(Sender: TObject);
  108.     procedure DateiBttnClick(Sender: TObject);
  109.     procedure Edit1Exit(Sender: TObject);
  110.     procedure Edit3Exit(Sender: TObject);
  111.     procedure EditorFormNameInputExit(Sender: TObject);
  112.     procedure BrwFormNameInputExit(Sender: TObject);
  113.     procedure TableNameInputExit(Sender: TObject);
  114.     procedure DirInputExit(Sender: TObject);
  115.     procedure DBaseExpCheckClick(Sender: TObject);
  116.     procedure DBaseImpCheckClick(Sender: TObject);
  117.     procedure DBStruEditExit(Sender: TObject);
  118.     procedure DBStruBttnClick(Sender: TObject);
  119.     procedure FormKeyPress(Sender: TObject; var Key: Char);
  120.     procedure SaveTypBttnClick(Sender: TObject);
  121.     procedure AliasEditClick(Sender: TObject);
  122.     Private
  123.     DrawBitmap: TBitmap;
  124.     RecList,KeyList,IIDList: TStringList;
  125.     Sprache: Integer;
  126.     TypDateiName: String;
  127.     Procedure CheckButtons;
  128.     function DoFormCreation(const FormIdent: string): TForm;
  129.     function CreateEditorSource(const UnitIdent, FormIdent: string): TMemoryStream;
  130.     function CreateEditorForm(const FormIdent: string): TMemoryStream;
  131.     function DoBrwFormCreation(const FormIdent: string): TForm;
  132.     function CreateBrowserForm(const FormIdent: string): TMemoryStream;
  133.     function CreateBrowserSource(const UnitIdent, FormIdent,
  134.                    EdiUnitIdent, EdiFormIdent: string): TMemoryStream;
  135.     function CreateStru(Const FormIdent: String): TMemoryStream;
  136.     Procedure Update_Listen(i: Integer);
  137.     Procedure Setze_Sprache(S: Integer);
  138.   end;
  139.  
  140.   TIsamDialogExpert = class(TIExpert)
  141.   public  { Methods required by Delphi to define the expert }
  142.     function GetName: string; override;
  143.     function GetComment: string; override;
  144.     function GetGlyph: HBITMAP; override;
  145.     function GetStyle: TExpertStyle; override;
  146.     function GetState: TExpertState; override;
  147.     function GetIDString: string; override;
  148.     procedure Execute; override;
  149.   public
  150.   private
  151.   end;
  152.  
  153. implementation
  154.  
  155. Uses Db, Proxies, IStreams, DirAusw, UToolDll,
  156.      WntIsam1, WntIsam2, WntIsam3, WntIsam4,
  157.      VirtIntf, Inifiles;
  158.  
  159. {$R *.DFM}
  160. {$R EXPTISAM.RES}
  161.  
  162. procedure HandleException;
  163. begin
  164.   ToolServices.RaiseException(ReleaseException);
  165. end;
  166.  
  167. procedure WntvIsamDialogExpert(ToolServices: TIToolServices);
  168. var
  169.   D: TIsamMainForm;
  170.   ISourceStream, IFormStream, IStruStream: TIMemoryStream;
  171.   UnitIdent, FormIdent, BrwIdent: string[79];
  172.   BrwUnitIdent, BrwFileName, StruIdent: String;
  173.   UZahl,Code: Integer;
  174.   StruFileName,UStr, Dir: String;
  175.   FileName: TFileName;
  176.   IniFile : TIniFile;
  177. begin
  178.   if ToolServices = nil then Exit;
  179.   if ToolServices.GetNewModuleName(UnitIdent, FileName) then
  180.   begin
  181.     D := TIsamMainForm.Create(Application);
  182.     try
  183.       D.Edit1.Text:= '';
  184.       D.Edit3.Text:= '';
  185.       Inifile:= TIniFile.Create('ISAMEXPT.INI');
  186.       Dir:= IniFile.ReadString('EXPERT','PATH','');
  187.       D.Sprache:= IniFile.ReadInteger('EXPERT','LANGUAGE',0);
  188.       D.TblCreatCheck.Checked:= (IniFile.ReadInteger('EXPERT','CREATEBUTTON',0) = 1);
  189.       D.BrwSetupCheck.Checked:= (IniFile.ReadInteger('EXPERT','SETUPBUTTON',0) = 1);
  190.       D.DBaseExpCheck.Checked:= (IniFile.ReadInteger('EXPERT','DBASEEXPORT',0) = 1);
  191.       D.DBaseImpCheck.Checked:= (IniFile.ReadInteger('EXPERT','DBASEIMPORT',0) = 1);
  192.       IniFile.Free;
  193.       D.DirInput.Text:= Dir;
  194.       if D.ShowModal = mrOK then begin
  195.         Dir:= D.DirInput.Text;
  196.         Inifile:= TIniFile.Create('ISAMEXPT.INI');
  197.         IniFile.WriteString('EXPERT','PATH',Dir);
  198.         IniFile.WriteInteger('EXPERT','LANGUAGE',D.Sprache);
  199.         if D.TblCreatCheck.Checked then
  200.           IniFile.WriteInteger('EXPERT','CREATEBUTTON',1)
  201.         else
  202.           IniFile.WriteInteger('EXPERT','CREATEBUTTON',0);
  203.         if D.BrwSetupCheck.Checked then
  204.           IniFile.WriteInteger('EXPERT','SETUPBUTTON',1)
  205.         else
  206.           IniFile.WriteInteger('EXPERT','SETUPBUTTON',0);
  207.         if D.DBaseExpCheck.Checked then
  208.           IniFile.WriteInteger('EXPERT','DBASEEXPORT',1)
  209.         else
  210.           IniFile.WriteInteger('EXPERT','DBASEEXPORT',0);
  211.         if D.DBaseImpCheck.Checked then
  212.           IniFile.WriteInteger('EXPERT','DBASEIMPORT',1)
  213.         else
  214.           IniFile.WriteInteger('EXPERT','DBASEIMPORT',0);
  215.         IniFile.Free;
  216.         UnitIdent:= D.Edit1.Text;
  217.         if Pos('.',UnitIdent) > 0 then UnitIdent:= Copy(UnitIdent,1,Pos('.',UnitIdent)-1);
  218.         FormIdent:= D.EditorFormNameInput.Text;
  219.         if Pos('.',FormIdent) > 0 then FormIdent:= Copy(FormIdent,1,Pos('.',FormIdent)-1);
  220.         BrwUnitIdent:= D.Edit3.Text;
  221.         BrwIdent := D.BrwFormNameInput.Text;
  222.         FileName:= Dir + UnitIdent + '.PAS';
  223.         BrwFileName:= Dir + BrwUnitIdent + '.PAS';
  224.         if D.BrwCheck.Checked then begin
  225.           IFormStream := TIMemoryStream.Create(D.CreateBrowserF